﻿#include "databaseopreate.h"
#include "ui_databaseopreate.h"

#include <qmessagebox.h>

DatabaseOpreate::DatabaseOpreate(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DatabaseOpreate)
{
    ui->setupUi(this);
    setWindowTitle( "添加" );
}

DatabaseOpreate::~DatabaseOpreate()
{
    delete ui;
}

void DatabaseOpreate::updata_title(QString &str)
{
    setWindowTitle( str );
}

void DatabaseOpreate::on_cannelBtn_clicked()
{
    this->close();
}


void DatabaseOpreate::on_EnterBtn_clicked()
{
    Chinese = ui->ChinesetextEdit->toPlainText();
    English = ui->EnglishtextEdit->toPlainText();
    WordClass = ui->WordClassEdit->toPlainText() ;
    emit sendNewData( Chinese, English, WordClass );
}

void DatabaseOpreate::addFinishTrips( bool is )
{
    if ( is == true )
    {
        ui->ChinesetextEdit->clear();
        ui->EnglishtextEdit->clear();
        ui->WordClassEdit->clear();
        QMessageBox message(QMessageBox::NoIcon,QString::fromUtf8("提示"),QString::fromUtf8("增加完成"),
                            QMessageBox::Yes);
        message.exec();
    }
    else
    {
        QMessageBox message(QMessageBox::NoIcon,QString::fromUtf8("提示"),QString::fromUtf8("请正确输入参数"),
                            QMessageBox::Yes);
        message.exec();
    }
}

